package com.happyrecyclingstation.controller.hr;

import com.happyrecyclingstation.service.MessageService;
import com.happyrecyclingstation.utils.Result;
import com.happyrecyclingstation.vo.ContactVO;
import com.happyrecyclingstation.vo.MessageVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 企业用户
 */
@Slf4j
@RequestMapping("/hr/messages")
@RestController("hrMessageController")
public class MessageController {
    @Autowired
    private MessageService messageService;

    /**
     * 通过id获取联系人信息
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result getContact(@PathVariable("id") Integer id){
        log.info("获取联系人信息:{}", id);
        List<ContactVO> contactList = messageService.getContact(id);
        return Result.success(contactList);
    }

    /**
     * 获取历史消息
     * @param id
     * @return
     */
    @GetMapping
    public Result getHistoryMsg(Integer id){
        log.info("获取历史消息:{}", id);
        List<MessageVO> messageList =messageService.getHistoryMsg(id);
        return Result.success(messageList);
    }

    /**
     * 判断是否建立联系
     * @param id
     * @return
     */
    @GetMapping("/isContact/{id}")
    public Result isContact(@PathVariable("id") Integer id){
        log.info("判断是否建立联系:{}", id);
        Integer isContact = messageService.isContact(id);
        return Result.success(isContact);
    }
}
